#ifndef PROGRESSITEMDELEGATE_H
#define PROGRESSITEMDELEGATE_H

#include <QItemDelegate>
#include <QProgressBar>
#include <QApplication>

#include <QtGui/qitemdelegate.h>
#include <QtGui/qlistview.h>
#include <QtGui/qcombobox.h>
#include <QtSql/qsqlrelationaltablemodel.h>

class ProgressItemDelegate: public QItemDelegate
{
public:

    explicit ProgressItemDelegate(QObject *aParent = 0)
    : QItemDelegate(aParent){}
    void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
    {
        QStyleOptionProgressBar progressBarStyleOption;
        progressBarStyleOption.rect = option.rect;
        const int progress = index.data(Qt::DisplayRole).toInt();
        progressBarStyleOption.minimum = 0;
        progressBarStyleOption.maximum = 100;
        progressBarStyleOption.textAlignment = Qt::AlignCenter;
        progressBarStyleOption.progress = progress;
        progressBarStyleOption.text = QString("%1%").arg(progress);
        progressBarStyleOption.textVisible = true;
        QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarStyleOption, painter);
    }
};


#endif // PROGRESSITEMDELEGATE_H
